
//@符号表示 src路径
//导入aixos对象
import request from "@/utils/request"
//登录,data对象,传后端的数据
const login = (data) => {
    //调用axios
    //
    return request({

        // /api/login代理成 http://localhost:8081/login 进行访问
        url: "/api/admins/login",
        method: "post",
        //简化属性
         headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}
//分页获取admin数据
const adminget = () => {
    return request({
        url: "/api/admins/all",
        method: "get",
    })
}
//根据id查询用户
const findById = (id) => {
    return request({
        url: `/api/admin/detail/${id}`,
        method: "get",
    })
}
//根据id删除用户
const deleteById = (data) => {
    return request({
        url: `/api/admins/deleteAdmin`,
        method: "post",
        data
    })
}

//保存admin数据（用于新增和更新）数据格式json
const save = (data) => {
    return request({
        url: "/api/admin/save",
        method: "post",
        //表示请求的数据格式为json
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}

const saveEdit = (data) => {
    return request({
        url: "/api/admin/saveEdit",
        method: "post",
        //表示请求的数据格式为json
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}

const userpage = (data) => {
    return request({
        url: "/api/user/page",
        method: "post",
        data
    })
}
const register = (data) => {
    return request({
        url: "/api/admins/register",
        method: "post",
        //表示请求的数据格式为json
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}
//添加
const addAdmin = (data) => {
    return request({
        url: "/api/admins/addAdmin",
        method: "post",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}
//更新
const updateAdmin = (data) => {
    return request({
        url: "/api/admins/updateAdmin",
        method: "post",
        headers: { "Content-Type": "application/json;charset=utf-8" },
        data
    })
}

export { login, adminget, findById, deleteById, save, userpage, register, saveEdit, addAdmin, updateAdmin }
